<template>
	<wsPage title="汇率列表">
		<div slot="page_operate">
			<Button  @click="refresh"><Icon type="refresh"></Icon><span>刷新</span></Button>
		</div>
		<wsSmPanel @page-change="query">
			<div slot="list_operate">
				<Button  @click="">批量保存</Button>
                <Button  @click="">保存并立即生效</Button>
			</div>

			<div slot="list_data">
				<ws-table :data="table.data" style="width: 100%" class="emoji-list">
					<ws-table-column align="center" prop="currency" label="货币类型"></ws-table-column>
					<ws-table-column align="center" prop="withdrawMinAmount" label="最小提现金额">
                        <template slot-scope="scope">
                            <input v-model="scope.row.withdrawMinAmount" placeholder="请输入内容"   style="padding:0 7px;"  class="placeStyle"/>
                        </template>
                    </ws-table-column>
					<ws-table-column align="center" prop="withdrawHandlingChargeRate" label="提现手续费比例">
                        <template slot-scope="scope">
                            <input v-model="scope.row.withdrawHandlingChargeRate" placeholder="请输入内容"   style="padding:0 7px;"  class="placeStyle"/>
                        </template>
                    </ws-table-column>
                    <ws-table-column align="center" prop="withdrawHandlingChargeAmount" label="提现手续费">
                        <template slot-scope="scope">
                            <input v-model="scope.row.withdrawHandlingChargeAmount" placeholder="请输入内容"   style="padding:0 7px;"  class="placeStyle"/>
                        </template>
                    </ws-table-column>
					<ws-table-column align="center" prop="updateDate" label="最后修改时间"></ws-table-column>
				
					<ws-table-column align="center" width="120" label="操作">
						<template slot-scope="scope">
							<Button @click="saveExchangeRate(scope.row)" type="text" size="small">保存</Button>
      					</template>
					</ws-table-column>
				</ws-table>
			</div>
		</wsSmPanel>
	</wsPage>
</template>

<script>
	import Util from '../../../common/util.js';
	import Common from '../../../common/common.js';
	export default {
		data() {
			return {
				table: {
					data: []
                },
                obj: {
                    id: null,
                    currency: '',
                    withdrawMinAmount: '',
                    withdrawHandlingChargeAmount:'',
                    withdrawHandlingChargeRate:0.0,
                    updateDate:'',
                    type : ''
                },
                form: {
                    obj: {
                        id: null,
                        withdrawMinAmount: '',
                        withdrawHandlingChargeAmount: '',
                        withdrawHandlingChargeRate:0.0,
                        updateDate:'',
                        type:''
                    }
                }
			}
		},
		computed: {
	
		},
		mounted() {
			this.init();
		},
		methods: {
			init() {
				this.query();
            },
            /**
			 * 刷新
			 */
			refresh() {
                this.table.data = [];
				this.init();
			},
			/**
			 * 表单查询
			 */
			query() {

				const _this = this;
				this.axios.get('/ws/ops/platformFinanceSettings/condition').then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
                        this.table.data = res.data;
                        for(var i=0; i<this.table.data.length; i++){
                            this.obj = this.table.data[i];
                            var currency = this.table.data[i].name+'('+this.table.data[i].symbol+')';
                            this.obj.currency = currency;
                            this.table.data[i] = this.obj;
                        }
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
            },
            /**
             * 修改提现服务费比例
             */
            saveExchangeRate(row) {
                const _this = this;
                _this.form.obj.id = row.id;
                _this.form.obj.withdrawMinAmount = row.withdrawMinAmount;
                _this.form.obj.withdrawHandlingChargeAmount = row.withdrawHandlingChargeAmount;
                _this.form.obj.withdrawHandlingChargeRate = row.withdrawHandlingChargeRate;
                _this.form.obj.type = row.type;
                this.axios.post('/ws/ops/platformFinanceSetting', _this.form.obj).then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
                        _this.$Message.warning(resMeta.message);
                        this.refresh();
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
            },


		}
	}
</script>

<style scoped>
	.ws-form-select {
		width: 162px;
	}
	.title-row {
		padding: 10px;
	}
	.ws-icon {
		font-size: 30px;
	}
</style>
<style>
	img.emoji {
	    width: 2em !important;
	    height: 2em !important;
	}
    input::-webkit-input-placeholder{
        margin-left:20px !important;    
    }
    input:focus::-webkit-input-placeholder {
    color: red;
}
</style>